#ifndef HTTP_RESP_H
#define HTTP_RESP_H

#define MAX_HEADERS_LINE 256

/*下一步分析希望得到的东西？*/
typedef enum _parse{
	STATUS_LINE = 0 ,
	HEADER_LINE,
	BODY,
	FINISHED
}parse_status;

typedef struct _ver{
	int major_ver;/*主版本号*/
	int minor_ver;/*次版本号*/
}http_ver;

/*缓冲区起始地址，用于后期释放整个缓冲区时使用，注意：我们不用strdup另外申请缓冲区，所有操作都在都在这片缓冲区上完成*/
typedef struct _resp_buf{
	char *resp_buf;
	int resp_buf_size;
}http_packet;

/*状态行*/
typedef struct _status_line{
	http_ver ver;
	int status_code;
	char *phrase;
}http_status_line;

/*首部行*/
typedef struct _header_line{
	unsigned int   header_num;
	char *header[MAX_HEADERS_LINE];
	char *value[MAX_HEADERS_LINE];
}http_header_line;

/*数据部分*/
typedef struct _body{
	char *body;
	unsigned int   body_length;
}http_body;

/*响应报文*/
typedef struct _resp{
	//char *resp_buf;
	http_packet 	 packet_buf;
	http_status_line status_line;
	http_header_line header_line;
	http_body		 content;
}http_resp;

void http_resp_init_destroy_comm(http_resp *resp_p);

int http_resp_destroy(http_resp *resp_p);

int http_resp_init(http_resp *resp_p);

int http_set_resp_buf(char *resp_buf, int buf_size,http_resp *resp_p);

int parse_status_line(char *status_line, http_resp *resp_p);

int parse_header_line(char *header_line, http_resp *resp_p);

//int parse_resp_packet(char *resp_buf, int buf_size, http_resp *resp_p);
int parse_resp_packet(http_resp *resp_p);


#endif
